/*
 * @Author: szx
 * @Date: 2022-01-14 15:27:16
 * @LastEditTime: 2022-01-14 15:41:56
 * @Description: 
 * @FilePath: \leetcode\200-299\228\228.js
 */
/**
 * @param {number[]} nums
 * @return {string[]}
 */
var summaryRanges = function (nums) {
    const result = [];
    let s = 0;
    for (let i = 1; i <= nums.length; i++) {
        if (nums[i - 1] !== nums[i] - 1) {
            let str = s !== i - 1 ? nums[s] + '->' + nums[i - 1] : nums[s] + '';
            result.push(str);
            s = i;
        }
    }
    return result;
};